<!DOCTYPE html>
<html lang="zh-cn">
  <head>
    <meta charset="utf-8">
    <title>呼叫中心运营平台</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" type="text/css" href="/css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" href="/css/non-responsive.css">
    <link rel="stylesheet" type="text/css" href="/css/bootstrap-theme.css">
    <link rel="stylesheet" type="text/css" href="/css/global.css">
    <link rel="stylesheet" type="text/css" href="/css/agent.css">
  </head>
  <body>
    <nav class="navbar navbar-inverse navbar-static-top">
      <div class="container">
        <div class="navbar-header">
          <a class="navbar-brand" href="#"><img alt="Logo" src="/img/logo.png"></a>
          <a class="navbar-brand" href="#">运营平台</a>
        </div>
        <div id="navbar">
          <ul class="nav navbar-nav">
            <li><a href="/company">企业管理</a></li>
            <li><a href="/task">任务监控</a></li>
            <li><a href="/user">账户管理</a></li>
            <li class="active"><a href="/agent">座席管理</a></li>
            <li><a href="/sound">语音管理</a></li>
            <li><a href="/service">服务管理</a></li>
            <li class="dropdown">
              <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
                <span class="glyphicon glyphicon-cog" aria-hidden="true"></span> 系统管理
              </a>
              <ul class="dropdown-menu">
                <li><a href="/gateway">中继网关</a></li>
                <li><a href="/status">服务器状态</a></li>
                <li><a href="/logs">日志记录</a></li>
              </ul>
            </li>
          </ul>
          <ul class="nav navbar-nav navbar-right">
            <li><a><img class="img-circle icon" src="/img/<?php echo $user->icon; ?>.png" width="19" height="19"> <?php echo $user->name; ?></a></li>
            <li><a href="/logout"><span class="glyphicon glyphicon-log-out" aria-hidden="true"></span> 退 出</a></li>
          </ul>
        </div>
      </div>
    </nav>
    <div class="container box">
      <div>
        <ol class="breadcrumb">
          <li>当前位置:</li>
          <li>座席管理</li>
          <li class="active">座席列表</li>
          <li class="btn-group pull-right">
              <button type="button" class="btn btn-default dropdown-toggle btn-xs" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                <span class="glyphicon glyphicon-cog" aria-hidden="true"></span> 更多操作 <span class="caret"></span>
              </button>
              <ul class="dropdown-menu">
                <li><a href="/agent/create/<?php echo $company_id; ?>">添加座席</a></li>
                <li><a href="/agent/batch/<?php echo $company_id; ?>">批量管理</a></li>
              </ul>
          </li>
          <li class="cpy-list">
            <select onChange="show(this.value)">
              <?php
                 if (is_array($companys) && count($companys) > 0) {
                   foreach ($companys as $company) {
                     if ($company['id'] == $company_id) {
                       echo '<option value="',$company['id'],'" selected="selected">',$company['name'],'</option>',"\n";
                     } else {
                       echo '<option value="',$company['id'],'">',$company['name'],'</option>',"\n";
                     }
                   }
                 } else {
                   echo '<option disabled>没有可用企业</option>',"\n";
                 }
              ?>
            </select>
          </li>
          <li  class="cpy-help">请选择需要操作的企业公司名称</li>
        </ol>
      </div>
      <div>
        <table class="table table-condensed table-striped table-hover">
          <thead>
            <tr>
              <th>#</th>
              <th>座席帐号</th>
              <th>座席姓名</th>
              <th>座席类型</th>
              <th>所属公司</th>
              <th>最后登录时间</th>
              <th>最后登录IP地址</th>
              <th>创建时间</th>
              <th class="td-edit">删除操作</th>
              <th class="td-edit">编辑操作</th>
            </tr>
          </thead>
          <tbody class="text-muted">
            <?php
               if (is_array($agents) && count($agents) > 0) {
                 foreach ($agents as $agent) {
                   echo '<tr>',"\n";
                   echo '<td><span class="glyphicon glyphicon-user" aria-hidden="true"></span></td>',"\n";
                   echo '<td>',$agent['uid'],'</td>',"\n";
                   echo '<td>',$agent['name'],'</td>',"\n";

                   if ($agent['type'] == 2) {
                     echo '<td>质检座席</td>',"\n";
                   } else if ($agent['type'] == 3) {
                     echo '<td>普通座席</td>',"\n";
                   } else {
                      echo '<td>未知类型</td>',"\n";
                   }

                   echo '<td>',$companys[$agent['company']]['name'],'</td>',"\n";
                   echo '<td>',$agent['last_login'],'</td>',"\n";
                   echo '<td>',$agent['last_ipaddr'],'</td>',"\n";
                   echo '<td>',$agent['create_time'],'</td>',"\n";
                   echo '<td class="td-edit"><a class="btn btn-default btn-xs" href="javascript:;" onClick="deleteAgent(',"'",$agent['uid'],"'",')"><span class="glyphicon glyphicon-trash"></span> 删 除</a></td>',"\n";
                   echo '<td class="td-edit"><a class="btn btn-default btn-xs" href="javascript:;" onClick="showAgent(',$agent['uid'],')"><span class="glyphicon glyphicon-edit"></span> 查 看</a></td>',"\n";
                   echo '</tr>',"\n";             
                 }
               }
            ?>
        </table>
      </div>
    </div>
    <script type="text/javascript" src="/js/jquery.min.js"></script>
    <script type="text/javascript" src="/js/bootstrap.min.js"></script>
    <script type="text/javascript" src="/js/reqwest.min.js"></script>
    <script type="text/javascript" src="/js/layer.js"></script>
    <script type="text/javascript" src="/js/agent.js"></script>
    <script type="text/javascript">
      $('li.dropdown').mouseover(function() {   
        $(this).addClass('open');
      }).mouseout(function() {
        $(this).removeClass('open');
      });
    </script>
  </body>
</html>
